<template>
  <div class="my-swiper">
    <swiper :options="swiperOption">
      <!-- slides -->
      <!-- 滑动模块 -->
      <swiper-slide v-for="(item, index) in swiperImgs" :key="index">
        <img class="swiper-slide-img" :style="{height: height}" :src="item" />
      </swiper-slide>
      <!-- Optional controls -->
      <template v-slot:pagination>
        <div class="swiper-pagination"></div>
      </template>
    </swiper>
  </div>
</template>

<script>
import "swiper/dist/css/swiper.css";
import { swiper, swiperSlide } from "vue-awesome-swiper";
export default {
  name: "MySwiper",
  components: {
    swiper,
    swiperSlide
  },
  props: {
    // slide高度
    height: {
      type: String,
      default: "auto"
    },
    // swiper图片数据源
    swiperImgs: {
      type: Array,
      required: true,
      default: function() {
        return [];
      }
    }
  },
  data() {
    return {
      //swiper配置
      swiperOption: {
        //无限滑动
        loop: true,
        //自动轮播
        autoplay: true,
        //swiper高度 随着 slide 高度变化
        auotoHiehgt: true,
        //分页导航
        pagination: {
          //分页器对应的html元素
          el: ".swiper-pagination",
          //分页器类型
          type: "bullets",
          //分页器内的元素添加类名
          bulletsClass: "custom-bullet-class"
        }
      }
    };
  },
  computed: {},
  methods: {}
};
</script>
<style lang="scss" scoped>
.my-swiper .swiper-slide-img {
  width: 100%;
}
</style>